package returnvalue;

class GetDay{
	
	int leapYear(int year) {
		if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
  			return 29;
  		}else {
  			return 28;
  		}	
	}
	
	// 根据年月日
	int getDayOfYear(int year,int month,int day) {
		int sum = 0;
		sum += day;
		// 累计
		switch(month-1) {
	  	case 11:
	  		sum+=30;
	  	case 10:
	  		sum+=31;
	  	case 9:
	  		sum+=30;
	  	case 8:
	  		sum+=31;
	  	case 7:
	  		sum+=31;
	  	case 6:
	  		sum+=30;
	  	case 5:
	  		sum+=31;
	  	case 4:
	  		sum+=30;
	  	case 3:
	  		sum+=31;
	  	case 2:
	  		sum += leapYear(year);
	  	case 1:
	  		sum+=31;
	  	} 

		return sum;
	}
}

public class GetDayDemo {
	public static void main(String[] args) {
		GetDay get = new GetDay();
		int dayOfYear = get.getDayOfYear(2022, 9, 8);
		System.out.println(dayOfYear);
	}
}
